<template>
  <div class="container">
    <div class="todo-item" v-for="item in items" :key="item.id">
      <div class="todo-item-bd" :class="{completed:item.state}">{{item.content}}</div>
      <div class="todo-item-ft">
        <div class="del-btn" @click="remove(item.id)">删除</div>
        <div class="del-btn" @click="changeState(item.id,item.state)">完成</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TodoItem",
  props: ['items'],
  methods: {
    remove(id) {
      this.$emit('remove',id)
    },
    changeState(id){

      this.$emit('changeState',id)
    },
  },
}
</script>

<style scoped>
.todo-item{
  width:200px;
  display: flex;
  align-items: center;
  height:50px;
  line-height: 50px;
}
.todo-item-bd{
  flex:1;
}
.completed{
  text-decoration: line-through;

}
.todo-item-ft{
  display: flex;
  align-items: center;
}
.del-btn{
  padding:5px 10px;
  border-radius: 4px;
  border:1px solid #ccc;
  line-height: 14px;
  font-size: 12px;
  margin-left: 5px;
}
</style>